<template lang="pug">
  .container.homework__main
    .row.content__head
      .col-sm-3
        h2.side__menu__textbook 课本
        .side__menu__switch.side__menu__switch_teacher(@click.stop="selectBook")
          i.icon_switch_normal
          | 切换
        .side__menu__switch.side__menu__switch_teacher(@click.stop="addBook")
          i.icon_switch_normal
          | 添加
      .col-sm-9(v-show="!addNewTutorShow")
        h2.content__filter__title 内容
          small （共2345个资源）
        .content__filter
          .content__filter__date 2017.9.12-2017.9.12
          .content__filter__order 时间顺序
          .side__menu__switch.side__menu__switch_teacher(@click.stop="addNewTutor")
            i.icon_switch_normal
            | 新建
      .col-sm-9(v-show="addNewTutorShow")
        .add-list
          .list-title 作业辅导名称:
          .list-content
            input.content-input(type="input", placeholder="(空)")

      .col-sm-12(v-show="!addNewTutorShow")
        .split
    .row
      .col-sm-3
        h3.side__menu__dt 高二课本
        ul.side__menu__list
          li
            a(href="") 第11章   坐标平面有理数函数
            ul
              li
                a(href="") 二次函数
              li
                a(href="") 不等式方式
                ul
                  li
                    a(href="") 坐标平面有理数函数
      .col-sm-9(v-show="!addNewTutorShow")
        table.homework__tb
          tr
            td 作业名称
            td 作业状态
            td 创建时间
            td 操作
          tr(v-for="item in list")
            td {{item.homeworkName}}
            td {{item.homeworkStatus == "0" ? "未开始" : "已开始"}}
            td {{item.startTime || "-"}}
            td
              span(@click="toDetail(item)") 学情追踪
              span(@click="handleModifyTime") 开启时间
              span 导入视频
              span(@click="handleRuse") 复用
              span 删除

      .col-sm-9(v-show="addNewTutorShow")
        .add-list
          .list-title 状态:
          .list-content
            .share
              span.share-select
              span.share-text 共享
            .share
              span.share-select
              span.share-text 不共享

        .add-list-class
          .add-list
            .list-title 发布班级:
            .list-class
              .class-title
                span.class-select
                span.class-name  高中5班（23 / 37）
          .class-student-list
            .student(v-for="(student, index) in students")
              .span.student-select
              .span.student-name {{student.name}}
        .add-list-class
          .add-list
            .list-title 发布班级:
            .list-class
              .class-title
                span.class-select
                span.class-name  高中5班（23 / 37）
        .add-list
          .list-title 开始时间:
          .list-content
            input.content-input(type="input")
        .add-list
          .list-title 结束时间:
          .list-content
            input.content-input(type="input")
            span.time-tips 不选择时间 一直开放
        .add-list
          .list-btns
            a.btn.btn-save(href="javascript:void(0)", @click="addTutorSave") 保存
            a.btn.btn-reset(href="javascript:void(0)", @click="TutorReset") 重设

</template>

<style lang="scss" scoped>
  ::-webkit-input-placeholder {
    text-align: left;
  }
  :-moz-placeholder {
    text-align: left;
  }
  ::-moz-placeholder {
    text-align: left;
  }

  .homework__main {
    .content__head {
      .col-sm-3{
        background: #FAFAFA;
      }
    }
    .add-list-class {
      background: #FAFAFA;
      border-bottom: 1px solid #ECECEC;
      font-size: 12px;
      .class-student-list {
        margin-right: 28px;
        padding-left: 12%;
        .student {
          display: inline-block;
          margin-right: 28px;
          margin-top: 10px;
          margin-bottom: 20px;
          .student-select {
            width: 18px;
            height: 18px;
            border: 1px solid $teacherMainColor;
            float: left;
            margin-right: 10px;
            cursor: pointer;
          }
          .student-name {
            width: 48px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
    .add-list {
      background: #FAFAFA;
      height: 48px;
      line-height: 48px;
      font-size: 12px;
      border-bottom: 1px solid #ECECEC;
      .list-title {
        float: left;
        width: 12%;
        text-align: right;
        padding-right: 10px;
      }
      .list-content {
        .content-input {
          display: inline-block;
          width: 200px;
          height: 28px;
          line-height: 28px;
          padding-left: 10px;
          border: 1px solid #157EF2;
          color: #A5A5A5;
          border-radius: 4px;
          text-align: left;
        }
        .time-tips {
          color: #FF1905;
          padding-left: 8px;
        }
        .share {
          height: 18px;
          line-height: 18px;
          display: inline-block;
          margin-right: 24px;
          color: $teacherMainColor;
          .share-select {
            border: 1px solid #157EF2;
            border-radius: 4px;
            width: 18px;
            height: 18px;
            display: inline-block;
            vertical-align: middle;
            margin-right: 4px;
            cursor: pointer;
          }
        }
        .class-title {
          .class-select {
            border: 1px solid #157EF2;
            border-radius: 4px;
            width: 18px;
            height: 18px;
            display: inline-block;
            vertical-align: middle;
            margin-right: 4px;
            cursor: pointer;
          }
        }
      }
      .list-btns {
        text-align: center;
        .btn {
          width: 140px;
          display: inline-block;
          margin: 0 auto;
          border: 1px solid #157EF2;
          border-radius: 6px;
          background: #fff;
          color: #157EF2;
          font-size: 12px;
          cursor: pointer;
          padding: 4px 30px;
          box-sizing: border-box;
        }
        .btn:nth-child(even) {
          margin-left: 56px;
        }
        .btn:hover {
          background: $teacherMainColor;
          color: #fff;
        }
      }
    }

    .homework__tb {
      span {
        margin-right: 10px;
        cursor: pointer;
        color: $teacherMainColor;
      }
    }
    .side__menu__list {
      a {
        color: $teacherMainColor;
      }
    }
    .content__filter__order{
      margin-right: 50px;
    }
  }

</style>

<script>
  import api from 'api/tutorship'
  export default {
    data () {
      return {
        list: [],
        addNewTutorShow: false,
        students: [{
          student_id: 1,
          name: 'likaifu'
        }, {
          student_id: 2,
          name: 'mahuateng'
        }, {
          student_id: 3,
          name: '汉语'
        }, {
          student_id: 4,
          name: 'balabalabalbabababababab汉语'
        }, {
          student_id: 5,
          name: '程子昂'
        }, {
          student_id: 6,
          name: '欧阳蛤蟆'
        }, {
          student_id: 7,
          name: '欧阳蛤蟆'
        }, {
          student_id: 8,
          name: '欧阳蛤蟆'
        }, {
          student_id: 9,
          name: '欧阳蛤蟆'
        }]
      }
    },
    mounted () {
      api.getList('2', {
        studentid: '120176400199057431',
        from: 0,
        size: 10
      }).then((Response) => {
        const data = Response.data
        this.list = data.data.list
      })
    },
    methods: {
      toDetail (item) {
        this.$router.push('/teacher/tutorship/' + item.homeworkId)
      },
      addBook () {
        this.$store.commit('addLession', true)
      },
      selectBook () {
        this.$store.commit('switchLession', {
          teacher: true
        })
      },
      addNewTutor () {
        this.addNewTutorShow = true
        console.log('新建作业辅导')
      },
      addTutorSave () {
        this.addNewTutorShow = false
        console.log('save')
      },
      TutorReset () {
        this.addNewTutorShow = false
        console.log('reset')
      },
      handleRuse () {
        this.$store.commit('tutorModifyTime', false)
        this.$store.commit('reUseShow', true)
      },
      handleModifyTime () {
        this.$store.commit('tutorModifyTime', true)
      }
    }
  }
</script>

